﻿#include<iostream>
#include<vector>

class ArrayBinaryTree {
private:
	std::vector<int> tree;
public:
	ArrayBinaryTree(std::vector<int> _tree) {
		tree = _tree;
	}
	int size() {
		return tree.size();
	}
	int val(int i) {
		if (i < 0 || i>size())
			return INT32_MAX;
		return tree[i];
	}
	//提取索引为i节点的左子树节点的索引
	int left(int i) {
		return 2 * i + 1;
	}
	//提取索引为i节点的右子树节点的索引
	int right(int i) {
		return 2 * i + 2;
	}
	//提取索引为i节点的父节点的索引
	int parent(int i) {
		return (i - 1) / 2;
	}
	std::vector<int> levelOrder() {
		std::vector<int> res;
		//直接遍历数组
		for (int i = 0; i < size(); i++) {
			if (val(i) != INT32_MAX)
				res.push_back(val(i));
		}
		return res;
	}
};


int main() {
	std::cout << "cpp binary tree array version" << std::endl;
	std::cin.get();
}

